<?php
include "../../../lib/list.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<link rel="stylesheet" href="../../../css/list.css" type="text/css"></link>
<link rel="stylesheet" href="../../../css/insert.css" type="text/css"></link>
<script type="text/javascript" src="../../../js/jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../js/list.js"></script>
<script type="text/javascript">
function all_barcode_print(){
	if(check_p_confirm()){
		openBrWindow('','viewer','width=700, height=600,scrollbars=no,resizable=no');
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.target = 'viewer';
		form.action = 'all_barcode_print.php';
		form.method = 'post';
		form.submit();
		}
}

function modify_group(){
	if(check_p_confirm()){
		openBrWindow('','viewer','width=400, height=230,scrollbars=no,resizable=no');
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.mode.value = 'modify_group';
		form.target = 'viewer';
		form.action = 'modify_group.php';
		form.method = 'post';
		form.submit();
		}
		else{
			return;
		}
}
function modify_buyer(){
	if(check_p_confirm()){
		openBrWindow('','viewer','width=400, height=230,scrollbars=no,resizable=no');
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.mode.value = 'modify_buyer';
		form.target = 'viewer';
		form.action = 'modify_buyer.php';
		form.method = 'post';
		form.submit();
		}
		else{
			return;
		}
}
function modify_bumun(){
	if(check_p_confirm()){
		openBrWindow('','viewer','width=400, height=230,scrollbars=no,resizable=no');
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.mode.value = 'modify_bumun';
		form.target = 'viewer';
		form.action = 'modify_bumun.php';
		form.method = 'post';
		form.submit();
		}
		else{
			return;
		}
}
function product_delete(){
	if(check_p_confirm()){
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.mode.value = 'delete';
		form.target = 'right';
		form.action = 'query.php';
		form.method = 'post';
		form.submit();
		}
}
function product_modify(){
	if(check_p_confirm()){
		var form = document.getElementById("iframe").contentWindow.document.view;
		form.mode.value = 'modify';
		form.target = 'right';
		form.action = 'insert.php';
		form.method = 'post';
		form.submit();
		}
}

function check_p_confirm(){
	var form = document.getElementById("iframe").contentWindow.document.view;
    var chk_count = 0;
    for (var i=0; i<form.length; i++) {
        if (form.elements[i].name == "chk_no[]" && form.elements[i].checked)
            chk_count++;
    }
    if (!chk_count) {
        alert("게시물을 하나 이상 선택하세요.");
        return false;
    }
    return true;
}

function search(){
	document.search.target = 'iframe';
	document.search.action = 'iframe.php';
	document.search.method = 'post';
	document.search.submit();
}

var i;
function setup_category_change(){
    $("select[name='bigcategory']").change(update_middlecategory);
    $("select[name='middlecategory']").change(update_smallcategory);
}

function update_middlecategory(){
    i = $("select[name='bigcategory']").index(this); 
    var b_no = $("select[name='bigcategory']").eq(i).attr('value');
    $.get('../../../lib/category.php?b_no='+b_no,show_middlecategory);
    $.get('../../../lib/category.php?m_no=-1',show_smallcategory);
}

function update_smallcategory(){
    i = $("select[name='middlecategory']").index(this); 
    var m_no = $("select[name='middlecategory']").eq(i).attr('value');
    $.get('../../../lib/category.php?m_no='+m_no,show_smallcategory);
}

function show_middlecategory(res){
    $("select[name='middlecategory']").eq(i).html(res);
}

function show_smallcategory(res){
    $("select[name='smallcategory']").eq(i).html(res);
}

$(document).ready(setup_category_change);
</script>
</head>
<body>
	<div style="width: 1024px; padding: 10px;">
		<div
			style="border-bottom: 1px solid #e8e8e8; text-align: left; font-size: 12px; margin-bottom: 12px; color: #9a9a9a">:::
			상품 관리&nbsp;⇒&nbsp;상품 마스터</div>
		<form name="search" method="post" action="iframe.php" enctype=multipart/form-data>
			<div id=search>
					<input name="mode" value="search" type="hidden" />
		<ul>
			<li class="lable">바코드</li>
			<li class="value"><input type="text" size="20" name="barcode"  onkeyup="number_check(this)"/>
			</li>
			<li class="lable">판매단가</li>
			<li class="value"><input type="text" name="minprice" size="5"  onkeyup="number_check(this)"/>&nbsp;~&nbsp;<input type="text"
						name="maxprice" class="input" size="6"  onkeyup="number_check(this)"/>
			</li>
			<li class="lable">대분류</li>
			<li class="value">
			<select name="bigcategory" style="width:155px; margin-left:2px">
			<option value="-1">:: 대분류 선택 ::</option>
			<?
			$qry = "SELECT * FROM uatp_biggestcategory";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
		</ul>
		<ul>
			<li class="lable">상품명</li>
			<li class="value"><input type="text" size="20" name="name" />
			</li>
			<li class="lable">구매처</li>
			<li class="value">
			<select name="buyer" style="width:155px; margin-left:2px">
			<option value="">:: 전부 검색 ::</option>
			<?
			$qry = "SELECT * FROM uatp_buyer";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
			<li class="lable">중분류</li>
			<li class="value">			
			<select name="middlecategory" style="width:155px; margin-left:2px">
			<option value="">:: 중분류 선택 ::</option>
			</select>
			</li>
		</ul>
		<ul>
			<li class="lable">상품명(가나)</li>
			<li class="value"><input type="text" size="20" name="namegana" />
			</li>
			<li class="lable">소속부문</li>
			<li class="value">
			<select name="bumun" style="width:155px; margin-left:2px">
			<option value="">:: 전부 검색 ::</option>
			<?
			$qry = "SELECT * FROM uatp_bumun";
			$query = DBquery($qry);
			while($list = mysql_fetch_array($query)){
			?>
			<option value="<?=$list['no']?>"><?=$list['name']?></option>
			<?
			}
			mysql_close();
			?>
			</select>
			</li>
			<li class="lable">소분류</li>
			<li class="value">			
			<select name="smallcategory" style="width:155px; margin-left:2px">
			<option value="">:: 소분류 선택 ::</option>
			</select>
			</li>
		</ul>
		<ul>
		<li class="bottom">
		<a href="javascript:search()" class="button white small">&nbsp;검색하기&nbsp;</a>
		</li>
		</ul>
	</div>
	</form>
		<div style="float: left; padding: 5px;">
		<a href="javascript:all_barcode_print()" class="button black small" >&nbsp;바코드 인쇄&nbsp;</a>
		<a href="javascript:modify_group()" class="button blue small">&nbsp;그룹변경&nbsp;</a>
		<a href="javascript:modify_bumun()" class="button blue small">&nbsp;부문변경&nbsp;</a>
		<a href="javascript:modify_buyer()" class="button blue small">&nbsp;구매처변경&nbsp;</a>
		</div>
		<div style="float: right; padding: 5px;">
		<a href="javascript:product_delete();" class="button red small">&nbsp;삭제하기&nbsp;</a>
		<a href="javascript:product_modify();" class="button green small">&nbsp;수정하기&nbsp;</a>
		<a href="insert.php" class="button white small">&nbsp;입력하기&nbsp;</a>
		</div>
		<form name="view" method="post">
			<iframe src="iframe.php" id="iframe"
				name="iframe" frameborder="0" width="1050px" height="450px"></iframe>
		</form>
	</div>
</body>
</html>
